print "print you stupid idiot!!"
def reverseString(text):
    reverse = ""
    for c in sentence:
        reverse = c + reverse
    return reverse

def splitWords(text,bw):
    changed = ""
    for c in sentence:
        if c == " ":
            changed = changed + "X"
        elif c != ",":
            changed = changed + c 
    return changed

def reverseWords(text):
    newSentence = ""
    currentWord = ""
    wordList = []
    
    for c in sentence:
        if (c == " " or c == ",") and currentWord != "":
            wordList.append(currentWord)
            currentWord = ""
        else:
            currentWord = currentWord + c
            
    if currentWord != "":
        wordList.append(currentWord)
    
    for word in wordList:
        newSentence =  word + " " + newSentence

    return newSentence

sentence = raw_input()
BWSentence = reverseString(sentence)
print BWSentence
ChSentence = splitWords(sentence, "X")
print ChSentence
SwSentence = reverseWords(sentence)
print SwSentence
print ""
print "!!! snorom eyb doog"